package jff.gui.treetable.structure;

import javax.swing.event.TreeModelEvent;
import javax.swing.event.TreeModelListener;
import javax.swing.tree.DefaultMutableTreeNode;

public class TreeTableModelListener implements TreeModelListener {
	    
	
	@Override
	public void treeNodesChanged(TreeModelEvent e) {
	
		DefaultMutableTreeNode node;
	    node = (DefaultMutableTreeNode)
	    
	    (e.getTreePath().getLastPathComponent());

	        /*
	         * If the event lists children, then the changed
	         * node is the child of the node we have already
	         * gotten.  Otherwise, the changed node and the
	         * specified node are the same.
	         */
	    try {
	    	int index = e.getChildIndices()[0];
	    	node = (DefaultMutableTreeNode)
	    	(node.getChildAt(index));
	        
	    } catch
	    	(NullPointerException exc) {}

	    //System.out.println("The user has finished editing the node.");
	    //System.out.println("New value: " + node.getUserObject());
	}
	    
	@Override    
	public void treeNodesInserted(TreeModelEvent e) {}
	
	@Override
	public void treeNodesRemoved(TreeModelEvent e) {}
	
	@Override
	public void treeStructureChanged(TreeModelEvent e) {}
	
}